<div class="modal-body">
	<form id="user-form" name="user-form" class="form-horizontal">
		<input type="hidden" name="optionId" id="optionId" value="">
		<input type="hidden" name="createTime" id="createTime" data-flag="date" data-format="yyyy-MM-dd HH:mm:ss">
		<input type="hidden" name="deviceid" id="deviceid" value="">
		<div class="box-body">
			<div class="col-md-12">
				<div class="form-group">
					<label for="device" class="col-sm-2 control-label">设备名称</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="devicename" name="devicename" placeholder="设备名称" readonly />
					</div>
				</div>
				<div class="form-group">
					<label for="device" class="col-sm-2 control-label">预警项名称</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="optionname" name="optionname" placeholder="预警项名称" />
					</div>
				</div>
				<div class="form-group">
					<label for="monitor_item" class="col-sm-2 control-label">预警项说明</label>
					<div class="col-sm-8">
						<textarea rows="5" class="form-control" id="description" name="description" placeholder="预警项说明"></textarea>
					</div>
				</div>
			</div>
		</div>
		<!-- /.box-body -->
		<div class="box-footer text-right">
			<!--以下两种方式提交验证,根据所需选择-->
			<button type="button" class="btn btn-default" data-btn-type="cancel" onclick="dialog_close()">取消</button>
			<button type="button" class="btn btn-primary" data-btn-type="save" onclick="save_station_warnconfig()">提交</button>
		</div>
		<!-- /.box-footer -->
	</form>
</div>
<script type="text/javascript">
	$(document).ready(function(){
		getStationInfo( device );
	});
	
	function getStationInfo( device ){
		var url = "../../tbl_station_info/station/" + device;
		$.ajax({
			  url: url,
			  type : 'get',
			  async : false,
			  contentType: "application/json; charset=utf-8",
			  success: function( json ) {
				  if( json.data && json.data.station_name ){
					  $("#devicename").val( json.data.station_name + "["+ json.data.monitor_item +"]" );
					  $("#deviceid").val( json.data.station_id );
				  }
			  }
		});
	}
	
	function save_station_warnconfig(){
		var station_warnconfig = {};
		station_warnconfig.id = $("#station_infoId").val();
		station_warnconfig.optionname = $("#optionname").val();
		station_warnconfig.deviceid = $("#deviceid").val();
		station_warnconfig.description = $("#description").val();		
		var json_data = JSON.stringify( station_warnconfig );
		var url = "../../tbl_station_warnconfig/save";
		$.ajax({
			  url: url,
			  type : 'post',
			  async : false,
			  data: json_data,
			  contentType: "application/json; charset=utf-8",
			  dataType: "json",
			  success: function(json) {
				 global.alert( json.message );
				 $("#station_info_main").load("station/station_info_list.html");
				 Dtable_station_warnconfig.ajax.reload();
				 dialog_close();
			  }
		});
	}
	
	function dialog_close(){
		global.dialog.close()
	}
	
</script>